{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([56.2, 27.7, 96.1, 51.7])"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as  np\n",
    "\n",
    "x = np.array([56.2,27.7,96.1,51.7])\n",
    "\n",
    "x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[56.2],\n",
       "       [27.7],\n",
       "       [96.1],\n",
       "       [51.7]])"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x[:,np.newaxis] "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[  0. ,  28.5, -39.9,   4.5],\n",
       "       [-28.5,   0. , -68.4, -24. ],\n",
       "       [ 39.9,  68.4,   0. ,  44.4],\n",
       "       [ -4.5,  24. , -44.4,   0. ]])"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x[:,np.newaxis] - x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[   0.  ,  812.25, 1592.01,   20.25],\n",
       "       [ 812.25,    0.  , 4678.56,  576.  ],\n",
       "       [1592.01, 4678.56,    0.  , 1971.36],\n",
       "       [  20.25,  576.  , 1971.36,    0.  ]])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(x[:,np.newaxis] - x)**2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "y = np.array([9.7,71.0,51.9,65.1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 0.        , 67.60133135, 58.07624299, 55.58246126],\n",
       "       [67.60133135,  0.        , 71.01668818, 24.7145706 ],\n",
       "       [58.07624299, 71.01668818,  0.        , 46.32062176],\n",
       "       [55.58246126, 24.7145706 , 46.32062176,  0.        ]])"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "D = np.sqrt((x[:,np.newaxis]-x)**2 + (y[:,np.newaxis]-y)**2)\n",
    "\n",
    "D"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
